﻿using System.Collections.Generic;

namespace TallyBook.DAL.Repository
{
    /// <summary>
    ///     仓储
    /// </summary>
    /// <typeparam name="TEntity"></typeparam>
    public interface IRepository<TEntity> where TEntity : class, new()
    {
        /// <summary>
        ///     根据主键id查询
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        TEntity Get(long id);

        /// <summary>
        ///     新增实体
        /// </summary>
        /// <param name="entity"></param>
        int Insert(TEntity entity);

        /// <summary>
        ///     更新实体
        /// </summary>
        /// <param name="entity"></param>
        int Update(TEntity entity);

        /// <summary>
        ///     删除实体
        /// </summary>
        /// <param name="entity"></param>
        int Delete(TEntity entity);

        /// <summary>
        ///     获取全部
        /// </summary>
        /// <returns></returns>
        List<TEntity> GetAll();
    }
}